<template>
  <view class="whe_maxv xd ccgl-y" style="background-color: #f8faf7">
    <view class="sy_bg" style="height: 350px"></view>
    <view class="jd pad_10 boxs" style="left: 0;width: 100%;top: 0">
      <view class="wh_f">
        <view class="flex_1">
          <view @click="addDetail(item)" v-for="(item,index) in list" :key="index">
            <view  v-if="index % 2 !== 1"
                   class="ba_white xyy boxs bor_10 mag_b_10">
              <view class="img_zfx">
                <view>
                  <img :src="item.image[0]" alt="">
                </view>
              </view>
              <view class="pad_10">
                <view class="fz_14 ccsl_1">
                  {{ item.name }}
                </view>
                <view class="pad_3_0">
                  <text class="wz_lv fz_10 bor_5 bor_1_hui" style="padding: 1px 7px">
                    {{ item.category_pstr }}
                  </text>
                </view>
                <view class="wh_f_l ">
                  <view class="wz_red fz_10">
                    ¥ <text class="fz_16">{{parseInt(item.price)}}</text>
                    <text>.{{ String(item.price).split('.')[1] }}</text>
<!--                    <text class="fz_12 mag_l-5">折后价</text>-->
                  </view>
                  <view>
                    <text @click.stop="pay(item)" class="qr_button fz_14" style="padding: 2px 12px;border-radius: 25px">购买</text>
                  </view>
                </view>
              </view>
            </view>
          </view>
        </view>
        <view style="width: 10px"></view>
        <view class="flex_1">
          <view @click="addDetail(item)" v-for="(item,index) in list" :key="index">
            <view  v-if="index % 2 !== 0"
                   class="ba_white xyy boxs bor_10 mag_b_10">
              <view class="img_zfx">
                <view>
                  <img :src="item.image[0]" alt="">
                </view>
              </view>
              <view class="pad_10">
                <view class="fz_14 ccsl_1">
                  {{ item.name }}
                </view>
                <view class="pad_3_0">
                  <text class="wz_lv fz_10 bor_5 bor_1_hui" style="padding: 1px 7px">
                    {{ item.category_pstr }}
                  </text>
                </view>
                <view class="wh_f_l ">
                  <view class="wz_red fz_10">
                    ¥ <text class="fz_16">{{parseInt(item.price)}}</text>
                    <text>.{{ String(item.price).split('.')[1] }}</text>
<!--                    <text class="fz_12 mag_l-5">折后价</text>-->
                  </view>
                  <view>
                    <text @click.stop="pay(item)" class="qr_button fz_14" style="padding: 2px 12px;border-radius: 25px">购买</text>
                  </view>
                </view>
              </view>
            </view>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>
<script>
import {addShoppingCart, getShopGoodsList, gettwoShopList, gwkList} from "../../Api/shop";

export default {
  name: "index",
  data(){
    return{
      tabList:[
        {id:1,name: '充值明细'},
        {id:2,name: '消费明细'},
      ],
      list:[],
      tabIndex: 1,
    }
  },
  onShow(){
    gwkList().then(res=>{
      this.list = res.data.data
    })
    // getShopGoodsList({category_id:456}).then(res=>{
    //   this.list = res.data.data
    // })
  },
  methods:{
    addDetail(e){
      const params = { id:e.id}; // 待传递的参数
      uni.navigateTo({
        url: `/shophome/shopDetail/index?id=${params.id}`
      });
    },
    pay(e){
        let data = {
          amount:1,
          checked:true,
          goods:e,
          goods_id:e.id
        }
      let list = encodeURIComponent(JSON.stringify([data]))
      uni.navigateTo({
        url:'/porder/orderPay/index?list='+list
      })
    },
    goWall(){
      uni.navigateTo({
        url: '/pagesList/userWallet/index'
      });
    },
    addTab(e){
      this.tabIndex = e.id
    }
  },

  onShareAppMessage() {
    return{
      title:'鲜到家族云享集市',
      path:'/pages/index/index'
    }
  },
  //2.配置分享到朋友圈
  onShareTimeline(){
    return{
      title: '鲜到家族云享集市',                //分享的标题
      query: '/pages/index/index',     //点击分享链接之后进入的页面路径
      imageUrl: '/static/img/logo.jpg' //分享发送的链接图片地址
    }
  }
}
</script>
<style scoped lang="scss">

</style>
